import request from "@/utils/request";
import type{ ItemModel } from "@/api/home";
//热门搜索关键词
export interface hotKeywordVOListModel {
    keyword: string;
    [searchName: string]: any,
}
export interface hotSearchModel {
    hotKeywordVOList: hotKeywordVOListModel[]
    [searchName: string]: any,
}

export interface ThisSearchDataModel {
    categoryInfoList: { categoryId: string, itemCount: number }[],
    categoryL1List: { id: string, name: string }[],
    directOrginQuery:string,
    hasMore:boolean,
    similarOrginQuery:string,
    directlyList: directlyModel[]
}
export interface directlyModel extends ItemModel {
    skuList:any[]
}




export default{
    //获取搜索的热门数据
    reqGetHotSearch(){
        return request.get<any,hotSearchModel>(`/dapi/xhr/search/init.json`);
    },
    //获取实时数据 https://m.you.163.com/xhr/search/searchAutoComplete.json 
    reqGetsearchrealtime(keywordPrefix:string){
        return request.get<any,string[]>(`/dapi/xhr/search/searchAutoComplete.json?keywordPrefix=${keywordPrefix}`,)
    },
    reqGetSearchData(keyword: string) {
        return request.get<any, ThisSearchDataModel>(`/dapi/xhr/search/search.json?__timestamp=1630133434953&needPopWindow=true&searchWordSource=7&stillSearch=false&_stat_search=autoComplete&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=${keyword}`)
    }
}